(function(vc){
    vc.extends({
        propTypes: {
           emitChooseChainInoutOrder:vc.propTypes.string,
           emitLoadData:vc.propTypes.string
        },
        data:{
            chooseChainInoutOrderInfo:{
                chainInoutOrders:[],
                _currentChainInoutOrderName:'',
            }
        },
        _initMethod:function(){
        },
        _initEvent:function(){
            vc.on('chooseChainInoutOrder','openChooseChainInoutOrderModel',function(_param){
                $('#chooseChainInoutOrderModel').modal('show');
                $that._refreshChooseChainInoutOrderInfo();
                $that._loadAllChainInoutOrderInfo(1,10,'');
            });
        },
        methods:{
            _loadAllChainInoutOrderInfo:function(_page,_row,_name){
                var param = {
                    params:{
                        page:_page,
                        row:_row,
                        communityId:vc.getCurrentCommunity().communityId,
                        name:_name
                    }
                };

                //发送get请求
               vc.http.apiGet('chainInoutOrder.listChainInoutOrder',
                             param,
                             function(json){
                                var _chainInoutOrderInfo = JSON.parse(json);
                                $that.chooseChainInoutOrderInfo.chainInoutOrders = _chainInoutOrderInfo.chainInoutOrders;
                             },function(){
                                console.log('请求失败处理');
                             }
                           );
            },
            chooseChainInoutOrder:function(_chainInoutOrder){
                if(_chainInoutOrder.hasOwnProperty('name')){
                     _chainInoutOrder.chainInoutOrderName = _chainInoutOrder.name;
                }
                vc.emit($props.emitChooseChainInoutOrder,'chooseChainInoutOrder',_chainInoutOrder);
                vc.emit($props.emitLoadData,'listChainInoutOrderData',{
                    chainInoutOrderId:_chainInoutOrder.chainInoutOrderId
                });
                $('#chooseChainInoutOrderModel').modal('hide');
            },
            queryChainInoutOrders:function(){
                $that._loadAllChainInoutOrderInfo(1,10,$that.chooseChainInoutOrderInfo._currentChainInoutOrderName);
            },
            _refreshChooseChainInoutOrderInfo:function(){
                $that.chooseChainInoutOrderInfo._currentChainInoutOrderName = "";
            }
        }

    });
})(window.vc);
